#! /bin/bash
# 主机信息 host.sh


while ((1))
do
    clear
    echo '
    ||===========================================================||
    ||   ______            __  __                  __  __      _ ||
    ||  / ____/___ _____  / / / /___  ____  ____ _/ / / /___ _(_)||
    || / /   / __ `/ __ \/ /_/ / __ \/ __ \/ __ `/ /_/ / __ `/ / ||
    ||/ /___/ /_/ / /_/ / __  / /_/ / / / / /_/ / __  / /_/ / /  ||
    ||\____/\__,_/\____/_/ /_/\____/_/ /_/\__, /_/ /_/\__,_/_/   ||
    ||                                   /____/                  ||
    ||===========================================================||
    ||        Linux System Information Management System         ||
    ||===========================================================||
    ||                         Main Menu                         ||
    ||===========================================================||
    ||         ID     |  Name                                    ||
    ||-----------------------------------------------------------||
    ||          1     |  主机名                                  ||
    ||-----------------------------------------------------------||
    ||          2     |  主机IP                                  ||
    ||-----------------------------------------------------------||
    ||          3     |  系统运行版本                            ||
    ||-----------------------------------------------------------||
    ||          4     |  系统发行版本                            ||
    ||-----------------------------------------------------------||
    ||          5     |  Linux硬盘大小                           ||
    ||-----------------------------------------------------------||
    ||          6     |  Linux系统内存大小                       ||
    ||-----------------------------------------------------------||
    ||          7     |  内存使用情况                            ||
    ||-----------------------------------------------------------||
    ||          8     |  CPU使用情况                             ||
    ||-----------------------------------------------------------||
    ||          9     |  硬盘容量                                ||
    ||===========================================================||
    '
  read -p 'Input your choice(Please enter 'quit/q' to return main menu): ' op
  case $op in
    1) echo "主机名"
       hostname;;
    2) echo "主机IP"
       ip addr | grep -E 'ens33$' | awk '{print $2}' | awk -F '/' '{print $1}';;
    3) echo "系统运行版本"
       cat /proc/version;;
    4) echo "系统发行版本"
       cat /etc/redhat-release;;
    5) echo "Linux硬盘大小"
       cd /usr/sbin;fdisk -l;;
    6) echo "Linux系统内存大小"
      cat /proc/meminfo | grep MemTotal;;
    7) echo "内存使用情况"
      free -h;;
    8) echo "CPU使用情况"
      top;;
    9) echo "硬盘容量"
       df -h;;    
    'quit') echo -e "\033[32mReturn main menu...\033[0m"
            exit;;
    'q') echo -e "\033[32mReturn main menu...\033[0m"
            exit;;
    *) echo -e '\033[31mInvalid choice, press return key to try again...\033[0m';;
  esac
  read sure
done

